#练习
# import math
# from  pprint import pprint
import datetime  #导入许多

import time
# from datetime import datetime as p_datetime
# print(time.localtime())
# #time.struct_time(tm_year=2021, tm_mon=1, tm_mday=5,
# # tm_hour=21, tm_min=36, tm_sec=43, tm_wday=1, tm_yday=5, tm_isdst=0)
#
# print(time.time())   #1609853871.385191

# now = time.localtime() #time.struct_time(tm_year=2021, tm_mon=1, tm_mday=5, tm_hour=21, tm_min=47, tm_sec=36, tm_wday=1, tm_yday=5, tm_isdst=0)
# print(now)
#
# now = time.strftime("%Y-%m-%d %H:%M:%S", now)
# print(now)  #2021-01-05 21:47:36
#
# print(type(now))  #<class 'str'>
#
# # 可以省略时间对象
# now1= time.strftime("%Y-%m-%d %H:%M:%S")
# print(now1)   #2021-01-05 21:47:36

# time_list = list(time.localtime())
# time_list[2] = 4  #[2021, 1, 4, 9,
# time.struct_time(time_list)
# print(time_list)  #[2021, 1, 4, 9, 47, 36, 2, 6, 0]

# # 获取计算机时间, 返回的是一个datetime.datetime对象
# print(datetime.datetime.today())
# print(type(datetime.datetime.today()))
#
# # 获取指定时区的时间
# print(datetime.datetime.now(tz=None))
# print(type(datetime.datetime.now(tz=None)))
#
# # 获取utc时间
# print(datetime.datetime.utcnow())
# print(type(datetime.datetime.utcnow()))

# 2021-01-06 09:52:37.083135
# <class 'datetime.datetime'>
# 2021-01-06 09:52:37.083135
# <class 'datetime.datetime'>
# 2021-01-06 01:52:37.083135
# <class 'datetime.datetime'>
#
# now = datetime.datetime.now(tz=None)
# print(now)
# print(type(now))
# # 2021-01-06 09:55:15.656253
# # <class 'datetime.datetime'>
#
# now1=now.strftime("%Y-%m-%d %H:%M:%S")
# print(now1)
# print(type(now1))
# # 2021-01-06 09:55:15
# # <class 'str'>
#
# #str` -> `datetime.datetime`
# now2=datetime.datetime.strptime(now1, "%Y-%m-%d %H:%M:%S")
# print(now2)
# print(type(now2))
#
# # 2021-01-06 10:19:28.812304
# # <class 'datetime.datetime'>
# # 2021-01-06 10:19:28
# # <class 'str'>
# # 2021-01-06 10:19:28
# # <class 'datetime.datetime'>
